﻿namespace PillBox.Client.Controls
{
    using System;
    using System.Windows;
    using PillBox.Client.Model;

    public class NoteTemplateSelector : ITemplateSelector
    {
        public DataTemplate NoteFromMeDataTemplate { get; set; }

        public DataTemplate NoteFromOtherDataTemplate { get; set; }

        public DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            DataTemplate template = NoteFromOtherDataTemplate;

            Note note = item as Note;

            if (note != null && note.From.ToLower() == "me")
            {
                template = NoteFromMeDataTemplate;
            }

            return template;
        }
    }
}